<?php
namespace Erp\C\Orders\Tn\Api;
use Erp\C\Orders\Tn\Api\ApiShippingModule;
use Fn;
class ApiWsModule extends ApiShippingModule{
    public $url,$header,$appToken,$appKey;
    public function __construct(){
        $this->appToken = 'd436b2a761b1675c4221b23dd03a09a0';
        $this->appKey= 'd436b2a761b1675c4221b23dd03a09a031f61076c73943e4187119bbf1b0bf91';
        $this->url = 'http://120.25.2.76:8080/default/svc/web-service';
        $this->header = array(
            "Content-Type:text/xml;charset=utf-8"
        );
    }
    /**
     * @param $jsonData
     * @return array
     * 创建线上包裹
     */
    public function createAndConfirmPackages($xmlData){
        $logFileName = "wsApiGetMultiCurl".date("H",time());
        Fn\App::log($logFileName,$xmlData,"纬狮国际墨西哥专线 请求TN Curl数据开始");
        $multi_request_res=$this->multiCurl($xmlData);
        Fn\App::log($logFileName,$multi_request_res,"纬狮国际墨西哥专线 请求TN Curl数据结束");
        return $multi_request_res;
    }

    /**
     *查询订单的tn号
     *@param array $xmlData xml格式的数据,  string 订单号 字符串形式 '111221'
     */
    public function findTnCreatePackage($data,$ordersId){
        $header = $this->header;
        $logFileName = 'mexico';
        if($logFileName){
            Fn\App::log($logFileName,$data,"纬狮国际墨西哥专线 findTN Curl数据开始");
        }
        $res = $this->oneHttpRequest($this->url,$data,'POST',$header);
        if($logFileName){
            Fn\App::log($logFileName,$res,"纬狮国际墨西哥专线 findTN Curl数据结束");
        }
        $response[$ordersId] = $res;
        return $response;
    }
    //api请求获取包裹标签pdf
    public function createPackageLable($data){
        $url = $this->url;
        $headers = $this->header;
        $response = $this->oneHttpRequest($url,$data,'POST',$headers);
        return $response;
    }
}